package com.ruoyi.tsjData.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.tsjData.domain.plat.DataTshjJx;
import com.ruoyi.tsjData.service.IDataTshjJxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提升机-间隙测试Controller
 * 
 * @author ruoyi
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/tsjData/jx")
@Api(value="提升机-间隙测试",tags = "提升机-间隙测试接口")
public class DataTshjJxController extends BaseController
{
    @Autowired
    private IDataTshjJxService dataTshjJxService;

    /**
     * 查询提升机-间隙测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:jx:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataTshjJx dataTshjJx)
    {
        startPage();
        List<DataTshjJx> list = dataTshjJxService.selectDataTshjJxList(dataTshjJx);
        return getDataTable(list);
    }

    /**
     * 导出提升机-间隙测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:jx:export')")
    @Log(title = "提升机-间隙测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTshjJx dataTshjJx)
    {
        List<DataTshjJx> list = dataTshjJxService.selectDataTshjJxList(dataTshjJx);
        ExcelUtil<DataTshjJx> util = new ExcelUtil<DataTshjJx>(DataTshjJx.class);
        util.exportExcel(response, list, "提升机-间隙测试数据");
    }

    /**
     * 获取提升机-间隙测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('tsjData:jx:query')")
    @GetMapping(value = "/{jxId}")
    public AjaxResult getInfo(@PathVariable("jxId") Long jxId)
    {
        return success(dataTshjJxService.selectDataTshjJxByJxId(jxId));
    }

    /**
     * 新增提升机-间隙测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:jx:add')")
    @Log(title = "提升机-间隙测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTshjJx dataTshjJx)
    {
        return toAjax(dataTshjJxService.insertDataTshjJx(dataTshjJx));
    }

    /**
     * 修改提升机-间隙测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:jx:edit')")
    @Log(title = "提升机-间隙测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTshjJx dataTshjJx)
    {
        return toAjax(dataTshjJxService.updateDataTshjJx(dataTshjJx));
    }

    /**
     * 根据id和任务id变更数据状态
     */
    @ApiOperation(value="根据id和任务id变更数据状态")
    @PreAuthorize("@ss.hasPermi('tsjData:jx:editByIdAndDataId')")
    @PostMapping("/editByIdAndDataId/{dataTaskId}/{jxId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "jxId", value = "间隙id", required = true, dataType = "Long"),
    })
    public AjaxResult editByIdAndDataId(@PathVariable("dataTaskId")Long dataTaskId, @PathVariable("jxId") Long jxId) {
        return toAjax(dataTshjJxService.updateDataTshjJxByJxId(dataTaskId, jxId));
    }

    /**
     * 删除提升机-间隙测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:jx:remove')")
    @Log(title = "提升机-间隙测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jxIds}")
    @ApiOperation(value="删除提升机-间隙测试")
    public AjaxResult remove(@PathVariable Long[] jxIds)
    {
        return toAjax(dataTshjJxService.deleteDataTshjJxByJxIds(jxIds));
    }
}
